package com.fancy.learncenter.ui.view;

import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.callback.OkOrCancelImpl;

/**
 * Created by shiweiwei on 2018/1/12.
 */

public class CartoonDoWorkExitPopu extends BasePopupWindow{

    private View rootView;
    private Button btnContineWork;
    private Button btnExitWork;
    private View layoutView;


    public void setListener(OkOrCancelImpl listener) {
        this.listener = listener;
    }

    private OkOrCancelImpl listener;

    public CartoonDoWorkExitPopu(Activity mContext, View layoutView) {
        super(mContext);
        this.layoutView = layoutView;
        initView();
    }

    private void initView(){
        rootView = LayoutInflater.from(mContext).inflate(R.layout.cartoon_do_work_exit_popu,null);
        btnContineWork = (Button) rootView.findViewById(R.id.btn_cartoon_contine_work);
        btnExitWork = (Button) rootView.findViewById(R.id.btn_exit_work);
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        setContentView(rootView);
        btnExitWork.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (listener != null){
                    listener.ok();
                }
            }
        });

        btnContineWork.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (listener != null){
                    listener.cancel();
                }
            }
        });
    }

    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

        showAtLocation(layoutView, Gravity.CENTER, 0, 0);
    }
}
